#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int main()
{
	int n, m, p, q;
	int a[100][100];
	int b[100][100] = { 0 };
	scanf("%d%d%d%d", &n, &m, &p, &q);
	int N = n / p, M = m / q;
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0;i < N;i++)
	{
		for (int j = 0;j < M;j++)
		{
			int max = a[i * p][j * q];
			for (int i1 = 0;i1 < p;i1++)
			{
				for (int j1 = 0;j1 < q;j1++)
				{
					if (max < a[i1 + i * p][j1 + j * q])
						max = a[i1 + i * p][j1 + j * q];
				}
			}
			b[i][j] = max;
		}
	}

	for (int i = 0;i < N;i++)
	{
		for (int j = 0;j < M;j++)
		{
			printf("%d ", b[i][j]);
			if (j == M - 1)
				printf("\n");
		}
	}

	return 0;
}